home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / lang / amigatalk.lha / intuition / DataType.st < prev    next >
Text File  |  2001-12-16  |  10KB  |  285 lines

  1. " ---------------------------------------------------------------------- "
  2. " DataType Class allows the user to access the DataType functions from   "
  3. " AmigaTalk."
  4. " ---------------------------------------------------------------------- "
  5.  
  6. Class DataType :Object ! private !
  7. [
  8.    newDTObject: dtName tags: tagArray
  9.  
  10.       " dtName is the name of a BOOPSI class gadget to make.  Returns 
  11.       * nil to 'private' if there is a problem, so verify that you
  12.       * receive something other than nil!
  13.       "
  14.       private <- <primitive 210 0 dtName tagArray>. "Create a new DataType Object"
  15.  
  16.       ^ private
  17. |
  18.    disposeDTObject: thisObject
  19.       <primitive 210 1 thisObject>  "Delete a DataType Object from memory"
  20. |
  21.    addDTObject: windowObj position: glistPos
  22.  
  23.       " Add a DataType Object to the given window & place it in 
  24.       * the glistPos slot.  Make sure that windowObj is a window
  25.       * address obtained by 'aWindow getWindowObject' or by
  26.       * 'amigatalk getWindowAddress: windowTitle'
  27.       "
  28.       ^ <primitive 210 2 windowObj glistPos private>
  29. |      
  30.    removeDTObject: windowObj
  31.  
  32.       " Remove a DataType Object from the given window: "
  33.       ^ <primitive 210 3 windowObj private>
  34. |
  35.    doAsyncLayout: layoutMsg
  36.  
  37.       " Call the DTM_ASYNCLAYOUT method on a separate AmigaOS process.
  38.       * layoutMsg is a gpLayout AmigaOS Object:
  39.       "
  40.       ^ <primitive 210 4 private layoutMsg>
  41. |
  42.    doDTMethod: windowObj req: reqObj msg: message
  43.  
  44.       " Perform the given DataType Method (message):"
  45.  
  46.       ^ <primitive 210 5 private windowObj reqObj message>
  47. |
  48.    getDTAttrs: tagArray
  49.  
  50.       " Retrieve the DataType attributes requested & place them in the
  51.       * given tagArray OBJECT, overwriting any old values found there.
  52.       "
  53.       ^ <primitive 210 6 private tagArray>
  54. |
  55.    getDTMethods
  56.  
  57.       " Retrieve an array of methods that the DataType object supports:"
  58.       ^ <primitive 210 7 private>
  59. |
  60.    getDTString: stringID
  61.  
  62.       " return a (error?) String for the given stringID Integer: "
  63.       ^ <primitive 210 8 stringID>
  64. |
  65.    getDTTriggerMethods
  66.  
  67.       " Retrieve an Array of DTMethod Objects that the DataType object
  68.       * responds to:
  69.       "
  70.       ^ <primitive 210 9 private>
  71. |
  72.    examineFile: filename attrs: tagArray
  73.  
  74.       " Examine the data that the file points to & 
  75.       * return a DataType record address that describes the data:
  76.       "
  77.       ^ <primitive 210 10 filename tagArray>
  78. |
  79.    examineClip: clipHandle attrs: tagArray
  80.  
  81.       " Examine the data that the clipboard handle points to & 
  82.       * return a DataType record address that describes the data:
  83.       "
  84.       ^ <primitive 210 11 clipHandle tagArray>
  85. |
  86.    printDTObject: windowObj req: reqObj prtObj: prtMsg
  87.  
  88.       " Tell the DataType Object to call the DTM_PRINT Method on a 
  89.       * separate process.  Returns true or false:
  90.       "
  91.       ^ <primitive 210 12 private windowObj reqObj prtMsg>
  92. |
  93.    refreshDTObject: windowObj attrs: tagArray
  94.  
  95.       " Refresh the object, by sending GM_RENDER to it: "
  96.       <primitive 210 13 private windowObj tagArray>
  97. |
  98.    releaseDTObject
  99.  
  100.       " Release a DataType struct obtained via ObtainDataTypeA()"
  101.       ^ <primitive 210 14 private>
  102. |
  103.    setDTAttrs: windowObj req: reqObj tags: tagArray
  104.  
  105.       " Set the attributes for a DataType Object.  nil returned on error:"
  106.       ^ <primitive 210 15 private windowObj reqObj tagArray>
  107. |
  108.    translateDTErrorNum
  109.       ^ <primitive 210 16>  "Return a string for the IoErr() code"
  110. |
  111.    copyDTMethods: theArray include: inclusions exclude: exclusions
  112.  
  113.       " Clone and modify DTA_Methods array.  nil returned on error: "
  114.       ^ <primitive 210 17 theArray inclusions exclusions>
  115. |
  116.    copyDTTriggerMethods: methods include: incl exclude: excl
  117.       
  118.       " Clone and modify DTA_TriggerMethods array.  nil returned on error: "
  119.       ^ <primitive 210 18 methods incl excl>
  120. |
  121.    obtainDomain: obj  window: windowObj  req: reqObj rport: rastPort 
  122.           which: type domain: domain    tags: attrTags 
  123.  
  124.       " Obtain the min/nom/max domains of a dt object.  This is equivalent
  125.       * to the DoDTDomainA() function call in C.
  126.       * On success, the domain box Object will be filled with the
  127.       * gadget's domain dimensions for this particular GDOMAIN_#? id.
  128.       * nil is returned if there is an error:
  129.       "
  130.       ^ <primitive 210 19 obj windowObj reqObj rastPort type domain attrTags>
  131. |
  132.    drawDTObject: obj rport: rastPort start: point1 end: point2 
  133.               h: htop    v: vtop     attrs: attrTags ! x y w h !
  134.  
  135.       " This method is used to draw a DataTypes object into a RastPort.
  136.       * This method can be used for strip printing the object or
  137.       * embedding it within a document.  Returns true if successful:
  138.       "
  139.       x <- point1 x.
  140.       y <- point1 y.
  141.       w <- point2 x.
  142.       h <- point2 y.
  143.  
  144.       ^ <primitive 210 20 obj rastPort x y w h htop vtop attrTags>
  145. |
  146.    findThisMethod: method in: methodsArrayObj 
  147.  
  148.       " Find a specified method in methods array.  Returns nil on error: "
  149.       ^ <primitive 210 21 methodsArrayObj method>
  150. |
  151.    findToolNode: toolList attrs: attrTags
  152.  
  153.       " This method searches for a given tool in a list of tool nodes. 
  154.       * nil is returned if there is an error:
  155.       "
  156.       ^ <primitive 210 22 toolList attrTags>
  157. |
  158.    findTriggerMethod: dtnObj command: cmdStr method: methodNumber
  159.  
  160.       " This Method searches for a given trigger method in a given methods
  161.       * array like that obtained from getDTTriggerMethods.
  162.       *
  163.       * If one of the 'command' or 'method' args matches a array item, this
  164.       * method returns a pointer to it.  Returns nil on error:
  165.       "
  166.       ^ <primitive 210 23 dtnObj cmdStr methodNumber>
  167. |
  168.    freeDTMethods: methodsArray
  169.  
  170.       " Free methods array obtained by CopyDT#?Methods. "
  171.       <primitive 210 24 methodsArray>
  172. |
  173.    getDTTriggerMethodDataFlags: methodNumber
  174.  
  175.       " This method returns the kind of data which can be attached
  176.       * to the stt_Data field in the dtTrigger method body.
  177.       *
  178.       * The data type can be specified by or'ing the method id (within
  179.       * STMF_METHOD_MASK value) with one of the STMD_#? identifiers:
  180.       *
  181.       *    STMD_VOID    - stt_Data MUST be NULL
  182.       *    STMD_ULONG   - stt_Data contains an unsigned long value
  183.       *    STMD_STRPTR  - stt_Data is a string pointer
  184.       *    STMD_TAGLIST - stt_Data points to an array of struct TagItem's,
  185.       *                   terminated with TAG_DONE
  186.       "
  187.       ^ <primitive 210 25 methodNumber>
  188. |
  189.    launchTool: toolObj project: projectString attrs: attrTags
  190.  
  191.       " This method launches an application with a specified project.
  192.       * The application and it's launch mode and other attributes are
  193.       * specified through the 'Tool' structure.
  194.       *
  195.       * INPUTS
  196.       * tool    - Pointer to a Tool structure.  nil is a valid arg.
  197.       * project - Name of the project to execute or nil.
  198.       * attrs   - Additional attributes.
  199.       *
  200.       * TAGS
  201.       *    NP_Priority (BYTE) - sets the priority of the launched tool
  202.       *                         Defaults to the current process's priority for
  203.       *    Shell and ARexx programs; Workbench applications
  204.       *    default to 0 except when overridden by the TOOLPRI tooltype.
  205.       *
  206.       *    NP_Synchronous (BOOL) - don't return until lauched application 
  207.       *                            process finishes.  Defaults to false.
  208.       * Returns false for failure, true otherwise.
  209.       "
  210.       ^ <primitive 210 26 toolObj projectString attrTags>
  211. |
  212.    lockDataType: dtObj
  213.  
  214.       " This method is used to lock a DataType structure obtained
  215.       * by examineFile:attrs:, examineClip:attrs: or a datatypes 
  216.       * object (DTA_DataType attribute).
  217.       *
  218.       * All calls to lockDataType, examineFile:attrs: or examineClip:attrs:
  219.       * must match the same number of releaseDataType calls, otherwise 
  220.       * havoc will break out:
  221.       "
  222.       <primitive 210 27 dtObj>
  223. |
  224.    obtainDTDrawInfo: object attrs: attrTags
  225.  
  226.       " This method is used to prepare a DataTypes object for
  227.       * drawing into a RastPort.
  228.       *
  229.       * This method will send the DTM_OBTAINDRAWINFO method
  230.       * to the object using the opSet message structure.
  231.       * Returns nil on error, an Integer handle (for releaseDTDrawInfo:handle:)
  232.       * otherwise:
  233.       "
  234.       ^ <primitive 210 28 object attrTags>
  235. |
  236.    releaseDTDrawInfo: anObject handle: aHandle
  237.  
  238.       " This method is used to release the information obtained
  239.       * with obtainDTDrawInfo:attrs:
  240.       *
  241.       * This method invokes the object's DTM_RELEASEDRAWINFO method
  242.       * using the dtReleaseDrawInfo message structure.
  243.       "
  244.       <primitive 210 29 anObject aHandle>
  245. |
  246.    saveDTObject: obj    window: windowObj  req: reqObj 
  247.            file: filename mode: filemode  flag: saveIconBool attrs: attrTags
  248.       
  249.       " This method saves the contents of an object into a file.
  250.       *
  251.       * The method opens the named file and saves the object's contexts
  252.       * into it (DTM_WRITE).  Then it closes the file.
  253.       * If the DTM_WRITE method returns success and saveIconBool is
  254.       * true, the matching icon is saved.
  255.       *
  256.       * If DTM_WRITE returns 0, the file will be deleted.  Returns nil on
  257.       * failure, an Integer otherwise.
  258.       "
  259.       ^ <primitive 210 30 obj windowObj reqObj filename filemode saveIconBool attrTags>  
  260. |
  261.    startDragSelect: onObject
  262.  
  263.       " This method starts drag-selection by the user (marking).
  264.       *
  265.       * This method replaces the old flag-fiddling method to
  266.       * start drag-select.
  267.       *
  268.       * The drag-select will only be started if the object supports
  269.       * DTM_SELECT, is in a window or requester and no layout-process
  270.       * is working on the object.  If all conditions are good, it sets
  271.       * the DTSIF_DRAGSELECT flag and returns true for success.
  272.       *   onObject is from 'newDTObject:tags:'
  273.       "
  274.       ^ <primitive 210 31 onObject>
  275. |
  276.    cleanupDataTypes
  277.  
  278.       " Use this method only once, when you are finished with your DataType 
  279.       * Object.  Using it more than once only slows the System down, no 
  280.       * other harm is done.  If you don't use this method, datatypes.library
  281.       * will remain open!
  282.       " 
  283.       <primitive 210 36>
  284. ]
  285.